//
//  YGDoctorMsgView.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/4/8.
//

#import "YGDoctorMsgView.h"

@interface YGDoctorMsgView ()

@property (nonatomic, strong) UILabel *memberNameLabel;
@property (nonatomic, strong) UILabel *mainTitleLabel;
@property (nonatomic, strong) UILabel *beGoodAtLabel;
@property (nonatomic, strong) UIButton *videoLogoBtn;
@property (nonatomic, strong) UIButton *videoTextBtn;
@property (nonatomic, strong) UIButton *imageLogoBtn;
@property (nonatomic, strong) UIButton *imageTextBtn;
@property (nonatomic, strong) UIButton *headImageBtn;


@end

@implementation YGDoctorMsgView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initconstraints];
    }
    return self;
}

-(void)initView{
    [self addSubview:self.memberNameLabel];
    [self addSubview:self.mainTitleLabel];
    [self addSubview:self.beGoodAtLabel];
    [self addSubview:self.videoLogoBtn];
    [self addSubview:self.videoTextBtn];
    [self addSubview:self.imageLogoBtn];
    [self addSubview:self.imageTextBtn];
    [self addSubview:self.headImageBtn];
}

-(void)initconstraints{
    [self.memberNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top).offset(20);
            make.left.mas_equalTo(self.mas_left).offset(20);
            make.width.mas_equalTo(40);
            make.height.mas_equalTo(12);
    }];
    
    [self.mainTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top).offset(20);
            make.left.mas_equalTo(self.memberNameLabel.mas_right).offset(10);
            make.width.mas_equalTo(120);
            make.height.mas_equalTo(12);
    }];
    
    [self.beGoodAtLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.memberNameLabel.mas_bottom).offset(1);
            make.left.mas_equalTo(self.memberNameLabel.mas_left);
            make.width.mas_equalTo(150);
            make.height.mas_equalTo(50);
    }];
    
    [self.videoLogoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self.mas_bottom).offset(-20);
            make.left.mas_equalTo(self.memberNameLabel.mas_left);
            
            
    }];
    
    [self.videoTextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.videoLogoBtn.mas_centerY);
            make.left.mas_equalTo(self.videoLogoBtn.mas_right).offset(5);
            make.width.mas_equalTo(50);
            make.height.mas_equalTo(10);
    }];
    
    [self.imageLogoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self.videoLogoBtn.mas_bottom);
            make.left.mas_equalTo(self.videoTextBtn.mas_right).offset(20);
            
    }];
    
    [self.imageTextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.imageLogoBtn.mas_centerY);
            make.left.mas_equalTo(self.imageLogoBtn.mas_right).offset(5);
            make.width.mas_equalTo(50);
            make.height.mas_equalTo(10);
    }];
    
    [self.headImageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.mas_centerY);
            make.left.mas_equalTo(self.beGoodAtLabel.mas_right).offset(20);
            make.right.mas_equalTo(self.mas_right).offset(-15);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(100);
    }];
}

//医生信息接口
- (void)updateDoctorMsgWith:(YGDoctorMessageModel *)model{
    if (model) {
        NSString *btnUrl = model.headimgUrl;
        NSURL *url = [NSURL URLWithString:btnUrl];
        [self.headImageBtn sd_setBackgroundImageWithURL:url forState:UIControlStateNormal];
        
        NSString *memberName = model.memberName;
        self.memberNameLabel.text = memberName;
        
        NSString *mainTitle = model.mainTitle;
        self.mainTitleLabel.text = mainTitle;
        
        NSString *beGoodAt = model.beGoodAt;
        self.beGoodAtLabel.text =[self.beGoodAtLabel.text stringByAppendingString:beGoodAt];
    }
}

#pragma setter

- (UILabel *)memberNameLabel{
    if (!_memberNameLabel) {
        _memberNameLabel = [[UILabel alloc]init];
        _memberNameLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:13];
        _memberNameLabel.textColor = UIColorFromRGB(0x333333);
    }
    return _memberNameLabel;
}

- (UILabel *)mainTitleLabel{
    if (!_mainTitleLabel) {
        _mainTitleLabel = [[UILabel alloc]init];
        _mainTitleLabel.font = [UIFont systemFontOfSize:13];
        _mainTitleLabel.textColor = UIColorFromRGB(0x333333);
    }
    return _mainTitleLabel;
}

- (UILabel *)beGoodAtLabel{
    if (!_beGoodAtLabel) {
        _beGoodAtLabel = [[UILabel alloc]init];
        _beGoodAtLabel.font = [UIFont systemFontOfSize:13];
        _beGoodAtLabel.text = @"擅长:";
        _beGoodAtLabel.textColor = UIColorFromRGB(0x333333);
        _beGoodAtLabel.numberOfLines = 0;
    }
    return _beGoodAtLabel;
}

- (UIButton *)videoLogoBtn{
    if (!_videoLogoBtn) {
        _videoLogoBtn = [[UIButton alloc]init];
        [_videoLogoBtn setBackgroundImage:[UIImage imageNamed:@"video_logo_icon"] forState:UIControlStateNormal];
    }
    return _videoLogoBtn;
}
- (UIButton *)videoTextBtn{
    if (!_videoTextBtn) {
        _videoTextBtn = [[UIButton alloc]init];
        [_videoTextBtn setTitle:@"视频问诊" forState:UIControlStateNormal];
        [_videoTextBtn setTitleColor:UIColorFromRGB(0x37C8D7) forState:UIControlStateNormal];
        _videoTextBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _videoTextBtn;
}

- (UIButton *)imageLogoBtn{
    if (!_imageLogoBtn) {
        _imageLogoBtn = [[UIButton alloc]init];
        [_imageLogoBtn setBackgroundImage:[UIImage imageNamed:@"video_logo_icon"] forState:UIControlStateNormal];
    }
    return _imageLogoBtn;
}

- (UIButton *)imageTextBtn{
    if (!_imageTextBtn) {
        _imageTextBtn = [[UIButton alloc]init];
        [_imageTextBtn setTitle:@"图文问诊" forState:UIControlStateNormal];
        [_imageTextBtn setTitleColor:UIColorFromRGB(0x37C8D7) forState:UIControlStateNormal];
        _imageTextBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    }
    return _imageTextBtn;
}

- (UIButton *)headImageBtn{
    if (!_headImageBtn) {
        _headImageBtn = [[UIButton alloc]init];
        _headImageBtn.layer.cornerRadius = 50;
        _headImageBtn.clipsToBounds = YES;
    }
    return _headImageBtn;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
